package cn.yunyichina.reservation.controller.business;

import cn.yunyichina.reservation.common.ResponseEnum;
import cn.yunyichina.reservation.constant.HttpResponse;
import cn.yunyichina.reservation.controller.BaseController;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Lullaby on 2016/8/25.
 */
@RestController
@RequestMapping("common")
public class CommonController extends BaseController {

    @GetMapping("enums")
    public HttpResponse getEnums(HttpServletRequest request) {
        HttpResponse httpResponse = new HttpResponse();
        String enumCodes = request.getParameter("enum_codes");
        if (StringUtils.isNotBlank(enumCodes)) {
            httpResponse.setData(getEnums(enumCodes));
        } else {
            httpResponse.failure(ResponseEnum.ILLEGAL_PARAMETER.getCode(), ResponseEnum.ILLEGAL_PARAMETER.getMessage());
        }
        return httpResponse;
    }

}
